import host from "./dev.js";
export default {
  get(url, data) {
    return requestMethod(url, "GET", data);
  },
  post(url, data) {
    return requestMethod(url, "POST", data);

  },
  put(url, data) {
    return requestMethod(url, "PUT", data);
  },
  delete(url, data) {
    return requestMethod(url, "DELETE", data);
  }
}
// 封装请求方法
function requestMethod(url, method, data) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: host + url,
      method,
      data,
      success: res => {
        if (res.statusCode == 200) {
          //获取接口数据 
          let rs = res.data;
          resolve(rs);
        } else {
          reject({});
        }

      },
      fail: err => {
        reject(err);
      }
    })
  });

}